package com.headFirstModel.commandPattern;

import com.headFirstModel.commandPattern.action.Light;
import com.headFirstModel.commandPattern.action.Strereo;
import com.headFirstModel.commandPattern.command.*;

/**
 * 测试组合遥控器
 */
public class RomoteLoader {
    public static void main(String[] args) {
        RomoteControl romoteControl=new RomoteControl();

        //创建电灯命令对象
        Light light=new Light();
        Command lightOnCommand=new LightOnCommand(light);
        Command lightOffCommand=new LightOffCommand(light);
        romoteControl.setCommand(0,lightOnCommand,lightOffCommand);

        //创建音响命令对象
        Strereo strereo=new Strereo();
        Command strereoOnCommand=new StrereoOnWithCommand(strereo);
        Command strereoOffCommand=new StrereoOffWithCommand(strereo);
        romoteControl.setCommand(1,strereoOnCommand,strereoOffCommand);

        //......
        System.out.println(romoteControl);

        romoteControl.onButtonWasPushed(0);
        romoteControl.onButtonWasPushed(1);
        romoteControl.offButtonWasPushed(0);
        romoteControl.offButtonWasPushed(1);

        romoteControl.undoButtonWasPushed();
        romoteControl.undoButtonWasPushed();
        romoteControl.undoButtonWasPushed();
        romoteControl.undoButtonWasPushed();
        romoteControl.undoButtonWasPushed();
    }
}
